<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:medistat="http://java.sun.com/jsf/composite/medistat">
<h:head>
	
</h:head>

<h:body>
	<ui:composition template="/template/common/commonLayout.xhtml">

		<ui:define name="content">
			<h:outputStylesheet library="css" name="table-style.css" />

			<h:form id="dataTableForm">
				<p:messages id="messages" />
				<c:if test="#{!addDoctorController.editMode}">
					<h1 style="color: #709FB3;">#{translatorService.translate('addDoctor.header')}</h1> 
				</c:if>
				<c:if test="#{addDoctorController.editMode}">
					<h1 style="color: #709FB3;">#{translatorService.translate('editDoctor.header')}</h1> 
				</c:if>
				<table width="100%">
					<tr>
						<td>
							<h:panelGrid columns="9" id="addDoctorContent">
								<h:outputText value="#{translatorService.translate('addDoctor.name')}:" />
								<h:inputText id="name" value="#{addDoctorController.name}"
									size="20" required="true" label="Name"
									onkeypress="return allowedChars(event,'0123456789.,')" />
					
								<h:message for="name" style="color:red" />
					
								<h:outputText value="#{translatorService.translate('addDoctor.surname')}:" />
								<h:inputText id="surname"
									value="#{addDoctorController.surname}" size="20"
									required="true" label="Surname"
									onkeypress="return allowedChars(event,'0123456789.,')" />
					
								<h:message for="surname" style="color:red" />
								
								<h:outputText value="#{translatorService.translate('addDoctor.status')}:" />
								<h:selectOneMenu id="status" styleClass="fieldSelection" value="#{addDoctorController.active}">
									<f:selectItems
										value="#{addDoctorController.getDiscreteValueProvider().getDiscreteValueSet('DoctorStatus')}" />
								</h:selectOneMenu>
								
								<h:message for="status" style="color:red" />
								
							</h:panelGrid>
							<p:spacer width="100%" height="10" />
							<h:panelGrid columns="2" id="buttons">
								<p:commandButton value="#{translatorService.translate('addDoctor.button.add')}"
									actionListener="#{addDoctorController.addDoctor}" 
									update="dataTableForm"
									rendered="#{!addDoctorController.editMode}"/>
								<p:commandButton value="#{translatorService.translate('addDoctor.button.update')}"
									actionListener="#{addDoctorController.updateDoctor}" 
									update="dataTableForm"
									rendered="#{addDoctorController.editMode}"/>
								<p:commandButton value="#{translatorService.translate('addDoctor.button.cancel')}"
									actionListener="#{addDoctorController.cancelUpdate}" 
									update="dataTableForm"
									rendered="#{addDoctorController.editMode}"/>
							</h:panelGrid>
						</td>
					</tr>
					<tr>
						<td>
							<h:panelGroup>
								<p:dataTable id="editDoctorDatatable"
									value="#{addDoctorController.doctorList}" var="doctor"			
									paginator="true"
									rows="12"
									>
									<p:column>
										<f:facet name="header">
											<h:outputLabel value="#{translatorService.translate('addDoctor.summaryName')}" />
										</f:facet>
										<h:outputText
											value="#{addDoctorController.getDiscreteValueProvider().getDiscreteValue('Doctors', doctor.id)}" />
									</p:column>
									<p:column>
										<f:facet name="header">
									    	<h:outputText value="#{translatorService.translate('addDoctor.name')}"/>
										</f:facet>	
									    <h:outputText value="#{doctor.name}" />
									</p:column>
									<p:column>
										<f:facet name="header">
									    	<h:outputText value="#{translatorService.translate('addDoctor.surname')}" />
										</f:facet>
									    	<h:outputText value="#{doctor.surname}" />
									</p:column>
									<p:column>
										<f:facet name="header">
									    	<h:outputText value="#{translatorService.translate('addDoctor.status')}" />
										</f:facet>
									    	<h:outputText
												value="#{addDoctorController.getDiscreteValueProvider().getDiscreteValue('DoctorStatus', doctor.active)}" />
									</p:column>
									<p:column>
										<h:commandLink action="#{addDoctorController.editDoctor(doctor)}"
											value="#{translatorService.translate('addDoctor.link.edit')}"
											>
											<f:ajax execute=":dataTableForm:editDoctorDatatable"
												render="@form" />
										</h:commandLink>
									</p:column>
								</p:dataTable>
							</h:panelGroup>
						</td>
					</tr>
				</table>
			</h:form>

		</ui:define>
	</ui:composition>
</h:body>

</html>